$(function(){
    window.onload = function(){
        $.ajax({
            url:'http://localhost:3000/play/category',
            type:'get',
            success:function(res){
                // console.log(res);
                var str='';
                var str1='';
                $.each(res,function(index,item){
                    // console.log(item.list);
                    str += `
                    <li>
                    <div class="category"><span>${item.title}</span></div>
                    <ul class="ul2">
                        <li><img src="../images/cat_1.png"><p>空气进化器(21)</p></li>
                        <li><img src="../images/cat_2.png"><p>空气进化器</p></li>
                        <li><img src="../images/cat_3.png"><p>空气进化器</p></li>
                        <li><img src="../images/cat_4.png"><p>空气进化器</p></li>
                        <li><img src="../images/cat_5.png"><p>空气进化器</p></li>
                        <li><img src="../images/cat_6.png"><p>空气进化器</p></li>
                        <li><img src="../images/cat_7.png"><p>空气进化器</p></li>
                        <li><img src="../images/cat_8.png"><p>空气进化器</p></li>
                        <li><img src="../images/cat_9.png"><p>空气进化器</p></li>
                        <li><img src="../images/cat_10.png"><p>空气进化器</p></li> 
                    </ul>
                    <div style="clear: both;"></div>
                    <div class="box-1">
                        <ul class="ul3">
                            
                        </ul>
                    </div>
                </li>
                    `
                $.each(item.list,function(index1,item1){
                        console.log(item1.productName);
                      str1 += `
                      <li>${item1.productName}(${item1.nums})</li>
                      `
                })
                
                })
                
                $('.ul1').html(str);
                $('.ul3').html(str1);
               
            }
        })
    }

    $('.main-1 span').eq(0).click(function(){
        window.location.href = "../play/playnew.html";
    })
    $('.main-1 span').eq(1).click(function(){
        window.location.href = "../play/playhot.html";
    })
    $('.main-1 span').eq(2).click(function(){
        window.location.href = "../play/playcategory.html";
    })
    $('.main-1 span').css('cursor','pointer');



})